package top.serms.leetcode;

/**
 * @Author: SerMs
 * @Date: 2024/07/05 11 49
 * @Email: 1839928782@qq.com
 * @Blog: https://serms.top
 **/
public class LeetCode167 {
    public static void main(String[] args) {
        int[] arr = {5,25,75};
        int[] ints = twoSum(arr, 100);
        for (int anInt : ints) {
            System.out.print(anInt+" ");
        }
    }

    public static int[] twoSum(int[] numbers, int target) {
        int j = numbers.length - 1;
        for (int i = 0; i < j; ) {
            if (numbers[i] + numbers[j] == target) {
                return new int[]{i+1, j+1};
            }
            if (numbers[i] + numbers[j] > target) {
             --j;
            }
            else{
                ++i;
            }
        }
        return new int[]{};
    }
}
